import { Component } from 'react';

import { Field,Popup } from 'saltui';

import DB from '../../app/db';

import AngleRight from 'salt-icon/lib/AngleRight';
import SubmittedReports from './SubmittedReports.js';

export default class PageHome extends Component {



  constructor(props) {
    super(props);
    var label = props.label;

    this.state = {
      label:label
    };
  }


  componentDidUpdate(){
  }

 
  handleChange(value) {

    //var data = this.props.getData();
    var type = this.props.value;
    var year = this.props.year;
    var period = this.props.period;
    DB.ReportModuleAPI.getSubmittedReports({
      type:type,
      year:year,
      period:period
    }) 
    .then((content) => {
      var data = content;
      Popup.show(<SubmittedReports data={data}/>, {
        animationType: 'slide-up',
      });
    }).catch((error) => {
      console.error(error);
    });
     

  }


  showSlot(id) {
    this[id].show();
  }


  render() {
    const t = this;
    const angleIconProps = { fill: 'rgba(31,56,88,0.40)', width: 20, height: 20 };
    return (
       <div>
         <Field label={t.state.label} icon={<AngleRight {...angleIconProps} />}>
            <div onClick={t.handleChange.bind(t)}
        >查看已提交汇报</div>
          </Field>
      </div>
    );
  }
}

